package net.maku.module.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import net.maku.framework.common.utils.PageResult;
import net.maku.framework.common.utils.Result;
import net.maku.module.entity.AgVisitorVolume;
import net.maku.module.query.AgCategoryQuery;
import net.maku.module.query.AgVisitorVolumeQuery;
import net.maku.module.service.AgVisitorVolumeService;
import net.maku.module.vo.AgCategoryVO;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/visitorVolume")
@Tag(name = "访问量统计")
@AllArgsConstructor
public class AgVisitorVolumeController {

    private final AgVisitorVolumeService agVisitorVolumeService;



    @Operation(summary = "保存访问")
    @PostMapping("/saveVisitorVolume")
    public Result<String> saveVisitorVolume(@RequestBody AgVisitorVolume agVisitorVolume) {
        agVisitorVolume.setCreateTime(new Date());
        agVisitorVolumeService.save(agVisitorVolume);
        return Result.ok();
    }
    @Operation(summary = "根据条件查询访问量")
    @PostMapping("/getVisitorVolumeByParam")
    public Result<List<Map<String, Object>>> getVisitorVolumeByParam(@RequestBody AgVisitorVolumeQuery agVisitorVolumeQuery) {
        return Result.ok(agVisitorVolumeService.getVisitorVolumeByParam(agVisitorVolumeQuery));
    }

    @Operation(summary = "根据条件查询访问量")
    @PostMapping("/queryByParam")
    public Result<List<Map<String, Object>>> queryByParam(@RequestBody AgVisitorVolumeQuery agVisitorVolumeQuery) {
        return Result.ok(agVisitorVolumeService.queryByParam(agVisitorVolumeQuery));
    }

//    @Operation(summary = "查询栏目")
//    @PostMapping("/getList")
////    @PreAuthorize("hasAuthority('member:user:all')")
//    public Result<PageResult<AgCategoryVO>> getList(@RequestBody AgVisitorVolumeQuery query) {
//        PageResult<AgCategoryVO> page = agVisitorVolumeService.getList(query);
//        return Result.ok(page);
//    }


}
